import swagger from '@elysiajs/swagger'; //自动生成 API 文档：通过配置 Swagger 插件，可以自动生成符合 OpenAPI 规范的 API 文档。这些文档详细描述了 API 的端点、请求参数、响应格式等信息，方便开发者和其他团队成员理解和使用 API
import Elysia from 'elysia';
import logger from 'logixlysia';

import { AppRoutes } from './app.routes';
import { env } from './shared/infrastructure/env';

const app = new Elysia()
  .use(logger())
  .use(
    swagger({
      exclude: ['/swagger'],
      autoDarkMode: true,
      documentation: {
        info: {
          title: '🦊 Elysia Clean Architecture',
          description:
            'Clean Architecture pattern for ElysiaJS + Bun + Postgres.js',
          version: '1.0.0',
          license: {
            name: 'MIT',
            url: 'https://opensource.org/license/mit/',
          },
        },
      },
    }),
  )
  .use(AppRoutes);

app.listen({ port: env.PORT });

console.log(
  `🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`,
);
